{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## [ Chapter 14 - Question Answering with a Fine-tuned Large Language Model ] \n",
    "\n",
    "## Extractive Question Answering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from aips import *\n",
    "from IPython.display import display,HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Already up to date.\n"
     ]
    }
   ],
   "source": [
    "!cd data && [ ! -d \"question-answering\" ] && git clone --depth=1 https://github.com/ai-powered-search/question-answering\n",
    "!cd data && [ -d \"question-answering\" ] && cd question-answering && git pull "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Depends on outdoors collection built in Chapter 13\n",
    "#%run chapters/ch13/1.setting-up-the-outdoors-dataset.ipynb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def normalize(logits):\n",
    "    return (logits + abs(logits.min())) / (logits.max() + abs(logits.min()))\n",
    "\n",
    "#Thanks to this answer: https://stackoverflow.com/questions/28907480/convert-0-1-floating-point-value-to-hex-color#28907772\n",
    "def blend(color, alpha, base=[255,255,255]):\n",
    "    out = [int(round((alpha * color[i]) + ((1 - alpha) * base[i]))) for i in range(3)]\n",
    "    hxa = \"#\" + \"\".join([\"%02x\" % e for e in out])\n",
    "    return hxa\n",
    "\n",
    "def clean_token(token):\n",
    "    return token.replace(u\"Ġ\", \"_\").replace(\"<\", \"&lt;\").replace(\">\", \"&gt;\")\n",
    "\n",
    "def stylize(term, colors, logit, probs=True):\n",
    "    term = clean_token(term)\n",
    "    color = blend(colors,logit)\n",
    "    prob = str(logit)[:4]\n",
    "    if logit == 1.:\n",
    "        color = \"#00ff00\"\n",
    "    if len(prob) < 4:\n",
    "        prob = prob + \"0\"\n",
    "    token = f\"<span style='background-color:{color}'>{term}</span>\"\n",
    "    if probs:\n",
    "        token += f\"<sub>{prob}</sub>\"\n",
    "    return token"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Listing 14.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from transformers import AutoTokenizer, AutoModelForQuestionAnswering\n",
    "model_name = \"deepset/roberta-base-squad2\"\n",
    "tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
    "model = AutoModelForQuestionAnswering.from_pretrained(model_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Listing 14.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of tokens: 172\n",
      "Total number of start probabilities: 172\n",
      "Total number of end probabilities: 172\n"
     ]
    }
   ],
   "source": [
    "question = \"What are minimalist shoes\"\n",
    "context = \"\"\"There was actually a project done on the definition of what a minimalist shoe is and the result was \"Footwear providing minimal interference with the natural movement of the foot due to its high flexibility, low heel to toe drop, weight and stack height, and the absence of motion control and stability devices\". If you are looking for a simpler definition, this is what Wikipedia says, Minimalist shoes are shoes intended to closely approximate barefoot running conditions. 1 They have reduced cushioning, thin soles, and are of lighter weight than other running shoes, allowing for more sensory contact for the foot on the ground while simultaneously providing the feet with some protection from ground hazards and conditions (such as pebbles and dirt). One example of minimalistic shoes would be the Vibram FiveFingers shoes which look like this.\"\"\"\n",
    "\n",
    "inputs = tokenizer(question, context, add_special_tokens=True,\n",
    "                   return_tensors=\"pt\")\n",
    "input_ids = inputs[\"input_ids\"].tolist()[0]\n",
    "\n",
    "outputs = model(**inputs)\n",
    "start_logits_norm = normalize(outputs[0].detach().numpy())\n",
    "end_logits_norm = normalize(outputs[1].detach().numpy())\n",
    "\n",
    "print(f\"Total number of tokens: {len(input_ids)}\")\n",
    "print(f\"Total number of start probabilities: {start_logits_norm.shape[1]}\")\n",
    "print(f\"Total number of end probabilities: {end_logits_norm.shape[1]}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Listing 14.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h3>_shoes _intended _to _closely _approximate _bare foot _running _conditions</h3>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre><span style='background-color:#51a8ff'>&lt;s&gt;</span><sub>0.68</sub> <span style='background-color:#daedff'>What</span><sub>0.14</sub> <span style='background-color:#f7fbff'>_are</span><sub>0.03</sub> <span style='background-color:#b9dcff'>_minimalist</span><sub>0.27</sub> <span style='background-color:#f3f9ff'>_shoes</span><sub>0.04</sub> <span style='background-color:#f9fcff'>&lt;/s&gt;</span><sub>0.02</sub> <span style='background-color:#f7fbff'>&lt;/s&gt;</span><sub>0.03</sub> <span style='background-color:#8fc7ff'>There</span><sub>0.43</sub> <span style='background-color:#e1f0ff'>_was</span><sub>0.11</sub> <span style='background-color:#daedff'>_actually</span><sub>0.14</sub> <span style='background-color:#aad4ff'>_a</span><sub>0.33</sub> <span style='background-color:#b3d9ff'>_project</span><sub>0.29</sub> <span style='background-color:#d9ecff'>_done</span><sub>0.15</sub> <span style='background-color:#bfdfff'>_on</span><sub>0.24</sub> <span style='background-color:#a6d3ff'>_the</span><sub>0.34</sub> <span style='background-color:#a0cfff'>_definition</span><sub>0.37</sub> <span style='background-color:#e3f1ff'>_of</span><sub>0.10</sub> <span style='background-color:#b3d9ff'>_what</span><sub>0.29</sub> <span style='background-color:#99ccff'>_a</span><sub>0.40</sub> <span style='background-color:#96caff'>_minimalist</span><sub>0.41</sub> <span style='background-color:#cae4ff'>_shoe</span><sub>0.20</sub> <span style='background-color:#e9f4ff'>_is</span><sub>0.08</sub> <span style='background-color:#c7e3ff'>_and</span><sub>0.22</sub> <span style='background-color:#72b8ff'>_the</span><sub>0.55</sub> <span style='background-color:#9dceff'>_result</span><sub>0.38</sub> <span style='background-color:#c0dfff'>_was</span><sub>0.24</sub> <span style='background-color:#399cff'>_\"</span><sub>0.77</sub> <span style='background-color:#2390ff'>Foot</span><sub>0.86</sub> <span style='background-color:#8cc5ff'>wear</span><sub>0.45</sub> <span style='background-color:#62b0ff'>_providing</span><sub>0.61</sub> <span style='background-color:#55aaff'>_minimal</span><sub>0.66</sub> <span style='background-color:#85c2ff'>_interference</span><sub>0.47</sub> <span style='background-color:#bddeff'>_with</span><sub>0.25</sub> <span style='background-color:#a2d0ff'>_the</span><sub>0.36</sub> <span style='background-color:#8dc6ff'>_natural</span><sub>0.44</sub> <span style='background-color:#a0cfff'>_movement</span><sub>0.37</sub> <span style='background-color:#d3e9ff'>_of</span><sub>0.17</sub> <span style='background-color:#b4d9ff'>_the</span><sub>0.29</sub> <span style='background-color:#a3d1ff'>_foot</span><sub>0.35</sub> <span style='background-color:#9dceff'>_due</span><sub>0.38</sub> <span style='background-color:#c1e0ff'>_to</span><sub>0.24</sub> <span style='background-color:#7dbeff'>_its</span><sub>0.50</sub> <span style='background-color:#50a7ff'>_high</span><sub>0.68</sub> <span style='background-color:#7ebeff'>_flexibility</span><sub>0.50</sub> <span style='background-color:#b9dcff'>,</span><sub>0.27</sub> <span style='background-color:#69b3ff'>_low</span><sub>0.59</sub> <span style='background-color:#a6d3ff'>_heel</span><sub>0.34</sub> <span style='background-color:#d1e8ff'>_to</span><sub>0.17</sub> <span style='background-color:#a8d4ff'>_toe</span><sub>0.33</sub> <span style='background-color:#bbddff'>_drop</span><sub>0.26</sub> <span style='background-color:#c9e4ff'>,</span><sub>0.21</sub> <span style='background-color:#8cc5ff'>_weight</span><sub>0.45</sub> <span style='background-color:#d0e8ff'>_and</span><sub>0.18</sub> <span style='background-color:#a7d3ff'>_stack</span><sub>0.34</sub> <span style='background-color:#bbddff'>_height</span><sub>0.26</sub> <span style='background-color:#daecff'>,</span><sub>0.14</sub> <span style='background-color:#d1e8ff'>_and</span><sub>0.17</sub> <span style='background-color:#a2d0ff'>_the</span><sub>0.36</sub> <span style='background-color:#7abcff'>_absence</span><sub>0.52</sub> <span style='background-color:#d4e9ff'>_of</span><sub>0.17</sub> <span style='background-color:#8ac4ff'>_motion</span><sub>0.46</sub> <span style='background-color:#c7e3ff'>_control</span><sub>0.21</sub> <span style='background-color:#d5eaff'>_and</span><sub>0.16</sub> <span style='background-color:#a4d2ff'>_stability</span><sub>0.35</sub> <span style='background-color:#abd5ff'>_devices</span><sub>0.32</sub> <span style='background-color:#9fcfff'>\".</span><sub>0.37</sub> <span style='background-color:#6db6ff'>_If</span><sub>0.57</sub> <span style='background-color:#a5d2ff'>_you</span><sub>0.35</sub> <span style='background-color:#e2f1ff'>_are</span><sub>0.11</sub> <span style='background-color:#a0cfff'>_looking</span><sub>0.37</sub> <span style='background-color:#bfdfff'>_for</span><sub>0.24</sub> <span style='background-color:#97cbff'>_a</span><sub>0.40</sub> <span style='background-color:#90c7ff'>_simpler</span><sub>0.43</sub> <span style='background-color:#a2d0ff'>_definition</span><sub>0.36</sub> <span style='background-color:#e0efff'>,</span><sub>0.12</sub> <span style='background-color:#8ec6ff'>_this</span><sub>0.44</sub> <span style='background-color:#e2f1ff'>_is</span><sub>0.11</sub> <span style='background-color:#b4daff'>_what</span><sub>0.29</sub> <span style='background-color:#87c3ff'>_Wikipedia</span><sub>0.47</sub> <span style='background-color:#dbedff'>_says</span><sub>0.14</sub> <span style='background-color:#c7e3ff'>,</span><sub>0.21</sub> <span style='background-color:#3499ff'>_Min</span><sub>0.79</sub> <span style='background-color:#b3d9ff'>imal</span><sub>0.29</sub> <span style='background-color:#c0dfff'>ist</span><sub>0.24</sub> <span style='background-color:#83c1ff'>_shoes</span><sub>0.48</sub> <span style='background-color:#3d9eff'>_are</span><sub>0.75</sub> <span style='background-color:#00ff00'>_shoes</span><sub>1.00</sub> <span style='background-color:#1b8cff'>_intended</span><sub>0.89</sub> <span style='background-color:#3b9dff'>_to</span><sub>0.76</sub> <span style='background-color:#3b9dff'>_closely</span><sub>0.76</sub> <span style='background-color:#56aaff'>_approximate</span><sub>0.66</sub> <span style='background-color:#5cadff'>_bare</span><sub>0.63</sub> <span style='background-color:#94c9ff'>foot</span><sub>0.41</sub> <span style='background-color:#76baff'>_running</span><sub>0.53</sub> <span style='background-color:#89c4ff'>_conditions</span><sub>0.46</sub> <span style='background-color:#9acdff'>.</span><sub>0.39</sub> <span style='background-color:#5fafff'>_1</span><sub>0.62</sub> <span style='background-color:#2692ff'>_They</span><sub>0.84</sub> <span style='background-color:#5eaeff'>_have</span><sub>0.62</sub> <span style='background-color:#46a2ff'>_reduced</span><sub>0.72</sub> <span style='background-color:#76baff'>_cushion</span><sub>0.53</sub> <span style='background-color:#badcff'>ing</span><sub>0.27</sub> <span style='background-color:#b9dcff'>,</span><sub>0.27</sub> <span style='background-color:#6ab4ff'>_thin</span><sub>0.58</sub> <span style='background-color:#9dceff'>_sol</span><sub>0.38</sub> <span style='background-color:#bedeff'>es</span><sub>0.25</sub> <span style='background-color:#bfdfff'>,</span><sub>0.24</sub> <span style='background-color:#a9d4ff'>_and</span><sub>0.33</sub> <span style='background-color:#82c0ff'>_are</span><sub>0.48</sub> <span style='background-color:#8ec6ff'>_of</span><sub>0.44</sub> <span style='background-color:#67b3ff'>_lighter</span><sub>0.59</sub> <span style='background-color:#92c8ff'>_weight</span><sub>0.42</sub> <span style='background-color:#b5daff'>_than</span><sub>0.29</sub> <span style='background-color:#a0cfff'>_other</span><sub>0.37</sub> <span style='background-color:#7fbfff'>_running</span><sub>0.50</sub> <span style='background-color:#9fcfff'>_shoes</span><sub>0.37</sub> <span style='background-color:#add6ff'>,</span><sub>0.32</sub> <span style='background-color:#56aaff'>_allowing</span><sub>0.66</sub> <span style='background-color:#b8dbff'>_for</span><sub>0.27</sub> <span style='background-color:#62b0ff'>_more</span><sub>0.61</sub> <span style='background-color:#77bbff'>_sensory</span><sub>0.53</sub> <span style='background-color:#96caff'>_contact</span><sub>0.41</sub> <span style='background-color:#b8dcff'>_for</span><sub>0.27</sub> <span style='background-color:#a6d2ff'>_the</span><sub>0.34</sub> <span style='background-color:#92c8ff'>_foot</span><sub>0.42</sub> <span style='background-color:#b6daff'>_on</span><sub>0.28</sub> <span style='background-color:#afd7ff'>_the</span><sub>0.31</sub> <span style='background-color:#9acdff'>_ground</span><sub>0.39</sub> <span style='background-color:#abd5ff'>_while</span><sub>0.32</sub> <span style='background-color:#8dc6ff'>_simultaneously</span><sub>0.44</sub> <span style='background-color:#7bbdff'>_providing</span><sub>0.51</sub> <span style='background-color:#b0d7ff'>_the</span><sub>0.30</sub> <span style='background-color:#9ccdff'>_feet</span><sub>0.38</sub> <span style='background-color:#d0e7ff'>_with</span><sub>0.18</sub> <span style='background-color:#96cbff'>_some</span><sub>0.40</sub> <span style='background-color:#83c1ff'>_protection</span><sub>0.48</sub> <span style='background-color:#d2e8ff'>_from</span><sub>0.17</sub> <span style='background-color:#93c9ff'>_ground</span><sub>0.42</sub> <span style='background-color:#acd5ff'>_hazards</span><sub>0.32</sub> <span style='background-color:#ebf5ff'>_and</span><sub>0.07</sub> <span style='background-color:#b2d8ff'>_conditions</span><sub>0.30</sub> <span style='background-color:#deeeff'>_(</span><sub>0.12</sub> <span style='background-color:#eaf5ff'>such</span><sub>0.08</sub> <span style='background-color:#edf6ff'>_as</span><sub>0.07</sub> <span style='background-color:#a6d2ff'>_pe</span><sub>0.34</sub> <span style='background-color:#d9ecff'>b</span><sub>0.14</sub> <span style='background-color:#d5eaff'>bles</span><sub>0.16</sub> <span style='background-color:#e8f3ff'>_and</span><sub>0.09</sub> <span style='background-color:#add6ff'>_dirt</span><sub>0.32</sub> <span style='background-color:#c2e1ff'>).</span><sub>0.23</sub> <span style='background-color:#80bfff'>_One</span><sub>0.49</sub> <span style='background-color:#c6e2ff'>_example</span><sub>0.22</sub> <span style='background-color:#eaf4ff'>_of</span><sub>0.08</sub> <span style='background-color:#85c2ff'>_minimal</span><sub>0.47</sub> <span style='background-color:#e8f3ff'>istic</span><sub>0.09</sub> <span style='background-color:#cae4ff'>_shoes</span><sub>0.20</sub> <span style='background-color:#cce6ff'>_would</span><sub>0.19</sub> <span style='background-color:#e0efff'>_be</span><sub>0.12</sub> <span style='background-color:#8dc6ff'>_the</span><sub>0.44</sub> <span style='background-color:#66b2ff'>_V</span><sub>0.60</sub> <span style='background-color:#b9dcff'>ib</span><sub>0.27</sub> <span style='background-color:#cbe5ff'>ram</span><sub>0.20</sub> <span style='background-color:#90c7ff'>_Five</span><sub>0.43</sub> <span style='background-color:#c4e1ff'>F</span><sub>0.23</sub> <span style='background-color:#b9dcff'>ingers</span><sub>0.27</sub> <span style='background-color:#a8d4ff'>_shoes</span><sub>0.33</sub> <span style='background-color:#d4e9ff'>_which</span><sub>0.16</sub> <span style='background-color:#a6d2ff'>_look</span><sub>0.34</sub> <span style='background-color:#dbedff'>_like</span><sub>0.14</sub> <span style='background-color:#c1e0ff'>_this</span><sub>0.24</sub> <span style='background-color:#9acdff'>.</span><sub>0.39</sub> <span style='background-color:#ffffff'>&lt;/s&gt;</span><sub>0.00</sub></pre>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre><span style='background-color:#ff5eff'>&lt;s&gt;</span><sub>0.63</sub> <span style='background-color:#fff7ff'>What</span><sub>0.03</sub> <span style='background-color:#fff7ff'>_are</span><sub>0.03</sub> <span style='background-color:#fff6ff'>_minimalist</span><sub>0.03</sub> <span style='background-color:#ffcdff'>_shoes</span><sub>0.19</sub> <span style='background-color:#ff97ff'>&lt;/s&gt;</span><sub>0.40</sub> <span style='background-color:#ffb1ff'>&lt;/s&gt;</span><sub>0.30</sub> <span style='background-color:#fff7ff'>There</span><sub>0.03</sub> <span style='background-color:#fff4ff'>_was</span><sub>0.04</sub> <span style='background-color:#fff2ff'>_actually</span><sub>0.05</sub> <span style='background-color:#fffbff'>_a</span><sub>0.01</sub> <span style='background-color:#ffd9ff'>_project</span><sub>0.14</sub> <span style='background-color:#ffe2ff'>_done</span><sub>0.11</sub> <span style='background-color:#fff4ff'>_on</span><sub>0.04</sub> <span style='background-color:#fffeff'>_the</span><sub>0.00</sub> <span style='background-color:#ffcbff'>_definition</span><sub>0.20</sub> <span style='background-color:#fff0ff'>_of</span><sub>0.05</sub> <span style='background-color:#ffe5ff'>_what</span><sub>0.10</sub> <span style='background-color:#ffe9ff'>_a</span><sub>0.08</sub> <span style='background-color:#ffc4ff'>_minimalist</span><sub>0.22</sub> <span style='background-color:#ffa1ff'>_shoe</span><sub>0.36</sub> <span style='background-color:#ffbdff'>_is</span><sub>0.26</sub> <span style='background-color:#ffcfff'>_and</span><sub>0.18</sub> <span style='background-color:#fff3ff'>_the</span><sub>0.04</sub> <span style='background-color:#ffedff'>_result</span><sub>0.07</sub> <span style='background-color:#ffe7ff'>_was</span><sub>0.09</sub> <span style='background-color:#ffb5ff'>_\"</span><sub>0.29</sub> <span style='background-color:#ffb4ff'>Foot</span><sub>0.29</sub> <span style='background-color:#ff73ff'>wear</span><sub>0.54</sub> <span style='background-color:#ffb4ff'>_providing</span><sub>0.29</sub> <span style='background-color:#ff9dff'>_minimal</span><sub>0.38</sub> <span style='background-color:#ff87ff'>_interference</span><sub>0.47</sub> <span style='background-color:#ffc2ff'>_with</span><sub>0.23</sub> <span style='background-color:#ffcaff'>_the</span><sub>0.20</sub> <span style='background-color:#ffb0ff'>_natural</span><sub>0.30</sub> <span style='background-color:#ff56ff'>_movement</span><sub>0.66</sub> <span style='background-color:#ffb8ff'>_of</span><sub>0.27</sub> <span style='background-color:#ffaeff'>_the</span><sub>0.31</sub> <span style='background-color:#ff42ff'>_foot</span><sub>0.74</sub> <span style='background-color:#ffa6ff'>_due</span><sub>0.35</sub> <span style='background-color:#ffc7ff'>_to</span><sub>0.21</sub> <span style='background-color:#ffc5ff'>_its</span><sub>0.22</sub> <span style='background-color:#ffbeff'>_high</span><sub>0.25</sub> <span style='background-color:#ff67ff'>_flexibility</span><sub>0.59</sub> <span style='background-color:#ff9dff'>,</span><sub>0.38</sub> <span style='background-color:#ffb9ff'>_low</span><sub>0.27</sub> <span style='background-color:#ffaeff'>_heel</span><sub>0.31</sub> <span style='background-color:#ffd0ff'>_to</span><sub>0.18</sub> <span style='background-color:#ffafff'>_toe</span><sub>0.31</sub> <span style='background-color:#ff67ff'>_drop</span><sub>0.59</sub> <span style='background-color:#ffaeff'>,</span><sub>0.31</sub> <span style='background-color:#ffb2ff'>_weight</span><sub>0.30</sub> <span style='background-color:#ffe0ff'>_and</span><sub>0.12</sub> <span style='background-color:#ffc1ff'>_stack</span><sub>0.24</sub> <span style='background-color:#ff5cff'>_height</span><sub>0.63</sub> <span style='background-color:#ff9eff'>,</span><sub>0.38</sub> <span style='background-color:#ffcaff'>_and</span><sub>0.20</sub> <span style='background-color:#ffd8ff'>_the</span><sub>0.15</sub> <span style='background-color:#ffb5ff'>_absence</span><sub>0.29</sub> <span style='background-color:#ffd3ff'>_of</span><sub>0.17</sub> <span style='background-color:#ffc1ff'>_motion</span><sub>0.24</sub> <span style='background-color:#ff94ff'>_control</span><sub>0.42</sub> <span style='background-color:#ffd7ff'>_and</span><sub>0.15</sub> <span style='background-color:#ffafff'>_stability</span><sub>0.31</sub> <span style='background-color:#ff3dff'>_devices</span><sub>0.75</sub> <span style='background-color:#ff3bff'>\".</span><sub>0.76</sub> <span style='background-color:#ffdeff'>_If</span><sub>0.12</sub> <span style='background-color:#ffedff'>_you</span><sub>0.07</sub> <span style='background-color:#fff1ff'>_are</span><sub>0.05</sub> <span style='background-color:#ffe2ff'>_looking</span><sub>0.11</sub> <span style='background-color:#ffe4ff'>_for</span><sub>0.10</sub> <span style='background-color:#ffeaff'>_a</span><sub>0.08</sub> <span style='background-color:#ffbaff'>_simpler</span><sub>0.27</sub> <span style='background-color:#ff87ff'>_definition</span><sub>0.47</sub> <span style='background-color:#ffb5ff'>,</span><sub>0.29</sub> <span style='background-color:#ffebff'>_this</span><sub>0.07</sub> <span style='background-color:#fff8ff'>_is</span><sub>0.02</sub> <span style='background-color:#ffffff'>_what</span><sub>0.00</sub> <span style='background-color:#ffa4ff'>_Wikipedia</span><sub>0.35</sub> <span style='background-color:#ffb0ff'>_says</span><sub>0.30</sub> <span style='background-color:#ff8dff'>,</span><sub>0.44</sub> <span style='background-color:#ffc0ff'>_Min</span><sub>0.24</sub> <span style='background-color:#ffceff'>imal</span><sub>0.19</sub> <span style='background-color:#ffa6ff'>ist</span><sub>0.34</sub> <span style='background-color:#ff7dff'>_shoes</span><sub>0.50</sub> <span style='background-color:#ffbaff'>_are</span><sub>0.27</sub> <span style='background-color:#ff6bff'>_shoes</span><sub>0.58</sub> <span style='background-color:#ff97ff'>_intended</span><sub>0.40</sub> <span style='background-color:#ffaeff'>_to</span><sub>0.31</sub> <span style='background-color:#ffa6ff'>_closely</span><sub>0.34</sub> <span style='background-color:#ff9dff'>_approximate</span><sub>0.38</sub> <span style='background-color:#ffadff'>_bare</span><sub>0.32</sub> <span style='background-color:#ff99ff'>foot</span><sub>0.40</sub> <span style='background-color:#ff77ff'>_running</span><sub>0.53</sub> <span style='background-color:#00ff00'>_conditions</span><sub>1.00</sub> <span style='background-color:#ff3eff'>.</span><sub>0.75</sub> <span style='background-color:#ff47ff'>_1</span><sub>0.72</sub> <span style='background-color:#ffb1ff'>_They</span><sub>0.30</sub> <span style='background-color:#ffcdff'>_have</span><sub>0.19</sub> <span style='background-color:#ffbaff'>_reduced</span><sub>0.26</sub> <span style='background-color:#ffbeff'>_cushion</span><sub>0.25</sub> <span style='background-color:#ff79ff'>ing</span><sub>0.52</sub> <span style='background-color:#ffb6ff'>,</span><sub>0.28</sub> <span style='background-color:#ffbaff'>_thin</span><sub>0.27</sub> <span style='background-color:#ffb0ff'>_sol</span><sub>0.30</sub> <span style='background-color:#ff59ff'>es</span><sub>0.65</sub> <span style='background-color:#ff83ff'>,</span><sub>0.48</sub> <span style='background-color:#ffb4ff'>_and</span><sub>0.29</sub> <span style='background-color:#ffcdff'>_are</span><sub>0.19</sub> <span style='background-color:#ffe2ff'>_of</span><sub>0.11</sub> <span style='background-color:#ffb7ff'>_lighter</span><sub>0.28</sub> <span style='background-color:#ff48ff'>_weight</span><sub>0.71</sub> <span style='background-color:#ffc3ff'>_than</span><sub>0.23</sub> <span style='background-color:#ffd4ff'>_other</span><sub>0.16</sub> <span style='background-color:#ff9fff'>_running</span><sub>0.37</sub> <span style='background-color:#ff31ff'>_shoes</span><sub>0.80</sub> <span style='background-color:#ff60ff'>,</span><sub>0.62</sub> <span style='background-color:#ffc4ff'>_allowing</span><sub>0.23</sub> <span style='background-color:#ffd9ff'>_for</span><sub>0.14</sub> <span style='background-color:#ffc7ff'>_more</span><sub>0.21</sub> <span style='background-color:#ffb1ff'>_sensory</span><sub>0.30</sub> <span style='background-color:#ff6fff'>_contact</span><sub>0.56</sub> <span style='background-color:#ffcdff'>_for</span><sub>0.19</sub> <span style='background-color:#ffdbff'>_the</span><sub>0.14</sub> <span style='background-color:#ff96ff'>_foot</span><sub>0.41</sub> <span style='background-color:#ffd4ff'>_on</span><sub>0.16</sub> <span style='background-color:#ffcdff'>_the</span><sub>0.19</sub> <span style='background-color:#ff49ff'>_ground</span><sub>0.71</sub> <span style='background-color:#ff9dff'>_while</span><sub>0.38</sub> <span style='background-color:#ffa2ff'>_simultaneously</span><sub>0.36</sub> <span style='background-color:#ffd8ff'>_providing</span><sub>0.15</sub> <span style='background-color:#ffe7ff'>_the</span><sub>0.09</sub> <span style='background-color:#ffb1ff'>_feet</span><sub>0.30</sub> <span style='background-color:#ffdeff'>_with</span><sub>0.13</sub> <span style='background-color:#ffdeff'>_some</span><sub>0.12</sub> <span style='background-color:#ff81ff'>_protection</span><sub>0.49</sub> <span style='background-color:#ffd2ff'>_from</span><sub>0.17</sub> <span style='background-color:#ffb3ff'>_ground</span><sub>0.29</sub> <span style='background-color:#ff6bff'>_hazards</span><sub>0.57</sub> <span style='background-color:#ffd9ff'>_and</span><sub>0.15</sub> <span style='background-color:#ff52ff'>_conditions</span><sub>0.68</sub> <span style='background-color:#ffd0ff'>_(</span><sub>0.18</sub> <span style='background-color:#ffedff'>such</span><sub>0.07</sub> <span style='background-color:#fff2ff'>_as</span><sub>0.04</sub> <span style='background-color:#ffeaff'>_pe</span><sub>0.08</sub> <span style='background-color:#ffe9ff'>b</span><sub>0.08</sub> <span style='background-color:#ffaeff'>bles</span><sub>0.31</sub> <span style='background-color:#ffeeff'>_and</span><sub>0.06</sub> <span style='background-color:#ff63ff'>_dirt</span><sub>0.61</sub> <span style='background-color:#ff5cff'>).</span><sub>0.63</sub> <span style='background-color:#ffe7ff'>_One</span><sub>0.09</sub> <span style='background-color:#ffdaff'>_example</span><sub>0.14</sub> <span style='background-color:#fff6ff'>_of</span><sub>0.03</sub> <span style='background-color:#ffdfff'>_minimal</span><sub>0.12</sub> <span style='background-color:#ffc4ff'>istic</span><sub>0.23</sub> <span style='background-color:#ffa0ff'>_shoes</span><sub>0.37</sub> <span style='background-color:#fff2ff'>_would</span><sub>0.05</sub> <span style='background-color:#ffedff'>_be</span><sub>0.07</sub> <span style='background-color:#ffeaff'>_the</span><sub>0.08</sub> <span style='background-color:#ffdeff'>_V</span><sub>0.12</sub> <span style='background-color:#ffe7ff'>ib</span><sub>0.09</sub> <span style='background-color:#ffa5ff'>ram</span><sub>0.35</sub> <span style='background-color:#ffd1ff'>_Five</span><sub>0.18</sub> <span style='background-color:#ffc8ff'>F</span><sub>0.21</sub> <span style='background-color:#ff77ff'>ingers</span><sub>0.53</sub> <span style='background-color:#ff7bff'>_shoes</span><sub>0.51</sub> <span style='background-color:#ffe5ff'>_which</span><sub>0.10</sub> <span style='background-color:#ffe6ff'>_look</span><sub>0.09</sub> <span style='background-color:#ffe5ff'>_like</span><sub>0.10</sub> <span style='background-color:#ff92ff'>_this</span><sub>0.42</sub> <span style='background-color:#ff3eff'>.</span><sub>0.75</sub> <span style='background-color:#ffcfff'>&lt;/s&gt;</span><sub>0.18</sub></pre>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "start_tokens = []\n",
    "end_tokens = []\n",
    "terms = tokenizer.convert_ids_to_tokens(input_ids)\n",
    "start_token_id = 0\n",
    "end_token_id = len(terms)\n",
    "for i, term in enumerate(terms):\n",
    "    start_tokens.append(stylize(term, [0, 127, 255], start_logits_norm[0][i]))\n",
    "    end_tokens.append(stylize(term, [255, 0, 255], end_logits_norm[0][i]))    \n",
    "    if start_logits_norm[0][i] == 1.0:\n",
    "        start_token_id = i\n",
    "    if end_logits_norm[0][i] == 1.0:\n",
    "        end_token_id = i + 1\n",
    "        \n",
    "answer = terms[start_token_id:end_token_id]\n",
    "display(HTML(f'<h3>{clean_token(\" \".join(answer))}</h3>'))\n",
    "display(HTML(f'<pre>{\" \".join(start_tokens)}</pre>'))\n",
    "display(HTML(f'<pre>{\" \".join(end_tokens)}</pre>'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "&lt;s&gt; What _are _minimalist _shoes &lt;/s&gt; &lt;/s&gt; There _was\n",
      "_actually _a _project _done _on _the _definition _of _what\n",
      "_a _minimalist _shoe _is _and _the _result _was _\"\n",
      "Foot wear _providing _minimal _interference _with _the _natural _movement\n",
      "_of _the _foot _due _to _its _high _flexibility ,\n",
      "_low _heel _to _toe _drop , _weight _and _stack\n",
      "_height , _and _the _absence _of _motion _control _and\n",
      "_stability _devices \". _If _you _are _looking _for _a\n",
      "_simpler _definition , _this _is _what _Wikipedia _says ,\n",
      "_Min imal ist _shoes _are _shoes _intended _to _closely\n",
      "_approximate _bare foot _running _conditions . _1 _They _have\n",
      "_reduced _cushion ing , _thin _sol es , _and\n",
      "_are _of _lighter _weight _than _other _running _shoes ,\n",
      "_allowing _for _more _sensory _contact _for _the _foot _on\n",
      "_the _ground _while _simultaneously _providing _the _feet _with _some\n",
      "_protection _from _ground _hazards _and _conditions _( such _as\n",
      "_pe b bles _and _dirt ). _One _example _of\n",
      "_minimal istic _shoes _would _be _the _V ib ram\n",
      "_Five F ingers _shoes _which _look _like _this .\n",
      "&lt;/s&gt;\n"
     ]
    }
   ],
   "source": [
    "window = 9\n",
    "maximum = 58\n",
    "for i in range((len(terms) // window) + 1):\n",
    "    start = window * i\n",
    "    end = window * (i + 1)\n",
    "    print(clean_token(\" \".join(terms[start:end])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "58.0"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "174 / 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "29.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "58 / 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from transformers import RobertaTokenizerFast,PreTrainedTokenizerFast\n",
    "tokenizer2 = RobertaTokenizerFast.from_pretrained('roberta-base')\n",
    "assert isinstance(tokenizer2, PreTrainedTokenizerFast)\n",
    "\n",
    "def tokenize_dataset(examples, maximum_tokens=384, document_overlap=128):\n",
    "\n",
    "    #maximum_tokens = 384 # This will be the number of tokens in BOTH the question and context\n",
    "    #document_overlap = 128 # Sometimes we need to split the context into smaller chunks, so we will overlap with this window\n",
    "    pad_on_right = tokenizer.padding_side == \"right\"\n",
    "    \n",
    "    # Tokenize our examples with truncation and padding, but keep the overflows using a stride. This results\n",
    "    # in one example possible giving several features when a context is long, each of those features having a\n",
    "    # context that overlaps a bit the context of the previous feature.\n",
    "    tokenized_examples = tokenizer2(\n",
    "        examples[\"question\" if pad_on_right else \"context\"],\n",
    "        examples[\"context\" if pad_on_right else \"question\"],\n",
    "        truncation=\"only_second\" if pad_on_right else \"only_first\",\n",
    "        max_length=maximum_tokens,\n",
    "        stride=document_overlap,\n",
    "        return_overflowing_tokens=True,\n",
    "        return_offsets_mapping=True,\n",
    "        padding=\"max_length\"\n",
    "    )\n",
    "    \n",
    "    return tokenized_examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table cellpadding=0 cellspacing=0>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">There</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_was</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_actually</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_a</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_project</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_done</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_on</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_done</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_on</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_definition</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_what</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_a</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_what</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_a</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoe</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_is</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_result</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_result</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_was</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_\"</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">Foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">wear</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_providing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">Foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">wear</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_providing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimal</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_interference</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_with</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_natural</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_with</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_natural</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_movement</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_due</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_due</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_to</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_its</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_high</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_flexibility</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_high</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_flexibility</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_low</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_heel</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_to</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_toe</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_drop</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_to</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_toe</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_drop</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_weight</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_stack</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_height</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_stack</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_height</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_absence</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_absence</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_motion</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_control</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_stability</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_devices</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_stability</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_devices</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">\".</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_If</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_you</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_looking</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_you</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_looking</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_for</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_a</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_simpler</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_definition</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_simpler</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_definition</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_this</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_is</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_what</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_Wikipedia</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_says</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_what</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_Wikipedia</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_says</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_Min</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">imal</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">imal</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_intended</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_to</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_closely</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_intended</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_to</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_closely</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_approximate</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_bare</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_running</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_conditions</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_running</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_conditions</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">.</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_1</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_They</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_have</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_reduced</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_They</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_have</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_reduced</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_cushion</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_thin</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_sol</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_thin</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_sol</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">es</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_lighter</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_weight</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_than</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_other</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_running</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_than</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_other</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_running</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">,</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_allowing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_for</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_more</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_allowing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_for</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_more</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_sensory</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_contact</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_for</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_for</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_foot</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_on</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_ground</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_while</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_simultaneously</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_ground</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_while</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_simultaneously</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_providing</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_feet</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_with</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_some</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_feet</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_with</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_some</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_protection</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_from</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_ground</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_hazards</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_ground</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_hazards</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_conditions</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_(</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">such</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_as</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_pe</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">such</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_as</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_pe</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">b</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">bles</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_dirt</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">).</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_and</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_dirt</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">).</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_One</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_example</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimal</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">istic</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_of</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimal</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">istic</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_would</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_be</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_V</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_be</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_the</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_V</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ib</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ram</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_Five</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">F</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ingers</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_Five</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">F</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">ingers</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_which</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_look</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_like</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_this</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td></tr>\n",
       "<tr><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">What</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_are</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_minimalist</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_shoes</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_look</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_like</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">_this</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">.</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;/s&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;pad&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;pad&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;pad&gt;</td><td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">&lt;pad&gt;</td></tr>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example = {\"question\" : question, \"context\" : context}\n",
    "tokenized_examples = tokenize_dataset(example, maximum_tokens=16, document_overlap=3)\n",
    "windowed_inputs = tokenized_examples[\"input_ids\"]\n",
    "windows = [\"<table cellpadding=0 cellspacing=0>\"]\n",
    "for window in windowed_inputs:\n",
    "    row = tokenizer2.convert_ids_to_tokens(window)\n",
    "    rhtml = [\"<tr>\"]\n",
    "    for cell in row:\n",
    "        rhtml.append(f'<td style=\"font-size:0.9em;font-family:courier;margin:0;padding:0;\">{clean_token(cell)}</td>')\n",
    "    rhtml.append(\"</tr>\")\n",
    "    windows.append(\"\".join(rhtml))\n",
    "windows.append(\"</table>\")\n",
    "display(HTML(\"\\n\".join(windows)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Up next: [Question Answering Data Preparation](2.question-answering-data-preparation.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
